<?php

use App\Http\Controllers\AdConfigController;
use App\Http\Controllers\ReportController;
use App\Http\Controllers\WholeController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// 认证用户信息
Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

// API 路由分组
Route::middleware(['api', 'response.transform'])->prefix('v1')->group(function () {

    // Common API endpoints
//    Route::post('xxxx/test', [CommonController::class, 'test'])->name('api.xxxx.test');

    // Report-related API endpoints
    Route::prefix('report')->group(function () {
        Route::post('exposure', [ReportController::class, 'exposure'])->name('api.report.exposure');  // 曝光上报
        Route::post('click', [ReportController::class, 'click'])->name('api.report.click');  // 点击上报
        Route::post('download', [ReportController::class, 'download'])->name('api.report.download');  // 下载上报
    });

    // Ad-related API endpoints
    Route::prefix('ad')->group(function () {
        Route::post('config', [AdConfigController::class, 'adConfig'])->name('api.ad.config');  // 广告配置
    });

    Route::prefix('')->group(function () {
        Route::post('appPackageList', [WholeController::class, 'appPackageList']);  // 广告配置
    });
});
